<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>1.computed</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../js/vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      姓：<input type="text" v-model="firstName"> <br>
      名：<input type="text" v-model="lastName"> <br>
      全名：<span>{{fullName}}</span><br>
    </div>

    <script type="text/javascript">
      new Vue({
        el:'#demo',
        data:{
          firstName:'zhang',
          lastName:'san'
        },
        computed:{
          // 计算属性是无法进行异步计算的，所以以下代码并不能实现等一秒钟再算出fullName
          fullName(){
            return setTimeout(() => {
              return this.firstName + '-' + this.lastName
            },1000);
          },
        }
      })
    </script>
  </body>
</html>